package com.boat.starter.pulsar.common;

import org.apache.pulsar.client.api.SubscriptionInitialPosition;
import org.apache.pulsar.client.api.SubscriptionType;

import com.boat.starter.pulsar.annotation.PulsarMessageListener;
import com.boat.starter.pulsar.annotation.TxPulsarMessageListener;

import java.io.Serializable;

/**
 * Description: 自定义 message
 *
 * @author: zuomin (myleszelic@outlook.com)
 * @date 2021/07/31 13:28
 */
public class PulsarMessageListenerInfo implements Serializable {

    /**
     * topic名称
     */
    private String topic;
    
    /**
     *tags,多个以逗号分割
     */
    private String tags;

    /**
     * 订阅名称
     */
    private String subscriptionName;

    /**
     * 订阅模式
     */
    private SubscriptionType subscriptionType;

    /**
     * 订阅开始消费位置
     */
    private SubscriptionInitialPosition subscriptionInitialPosition;

    public PulsarMessageListenerInfo(PulsarMessageListener pulsarMessageListener) {
        this.topic = pulsarMessageListener.topic();
        this.tags = pulsarMessageListener.tags();
        this.subscriptionName = pulsarMessageListener.subscriptionName();
        this.subscriptionType = pulsarMessageListener.subscriptionType();
        this.subscriptionInitialPosition = pulsarMessageListener.subscriptionInitialPosition();
    }

    public PulsarMessageListenerInfo(TxPulsarMessageListener pulsarMessageListener) {
        this.topic = pulsarMessageListener.topic();
        this.tags = pulsarMessageListener.tags();
        this.subscriptionName = pulsarMessageListener.subscriptionName();
        this.subscriptionType = pulsarMessageListener.subscriptionType();
        this.subscriptionInitialPosition = pulsarMessageListener.subscriptionInitialPosition();
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		this.tags = tags;
	}

	public String getSubscriptionName() {
        return subscriptionName;
    }

    public void setSubscriptionName(String subscriptionName) {
        this.subscriptionName = subscriptionName;
    }

    public SubscriptionType getSubscriptionType() {
        return subscriptionType;
    }

    public void setSubscriptionType(SubscriptionType subscriptionType) {
        this.subscriptionType = subscriptionType;
    }

    public SubscriptionInitialPosition getSubscriptionInitialPosition() {
        return subscriptionInitialPosition;
    }

    public void setSubscriptionInitialPosition(SubscriptionInitialPosition subscriptionInitialPosition) {
        this.subscriptionInitialPosition = subscriptionInitialPosition;
    }

	@Override
	public String toString() {
		return "PulsarMessageListenerInfo [topic=" + topic + ", tags=" + tags + ", subscriptionName=" + subscriptionName
				+ ", subscriptionType=" + subscriptionType + ", subscriptionInitialPosition="
				+ subscriptionInitialPosition + "]";
	}
}
